package com.jyy.prefabricated.service.impl;

import com.jyy.prefabricated.entity.QuestionDetails;
import com.jyy.prefabricated.mapper.QuestionDetailsMapper;
import com.jyy.prefabricated.service.QuestionDetailsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 题目详情表(QuestionDetails)表服务实现类
 *
 * @author mrl
 * @since 2021-05-27 14:54:36
 */
@Service("questionDetailsService")
public class QuestionDetailsServiceImpl implements QuestionDetailsService {
    @Resource
    private QuestionDetailsMapper questionDetailsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public QuestionDetails queryById(Integer id) {
        return this.questionDetailsDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<QuestionDetails> queryAllByLimit(int offset, int limit) {
        return this.questionDetailsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param questionDetails 实例对象
     * @return 实例对象
     */
    @Override
    public QuestionDetails insert(QuestionDetails questionDetails) {
        this.questionDetailsDao.insert(questionDetails);
        return questionDetails;
    }

    /**
     * 修改数据
     *
     * @param questionDetails 实例对象
     * @return 实例对象
     */
    @Override
    public QuestionDetails update(QuestionDetails questionDetails) {
        this.questionDetailsDao.update(questionDetails);
        return this.queryById(questionDetails.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.questionDetailsDao.deleteById(id) > 0;
    }
}